package com.ddsso.auth.web.vo;
import java.lang.reflect.Field;

import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.shiro.authc.AuthenticationToken;
/**
 * @author zdd
 * @package com.ddsso.auth.web.vo
 * @Time Created by zdd on 2016/11/2.
 * @description To-do
 */
public class UserToken implements AuthenticationToken{
    private static final long serialVersionUID = 1L;

    // 用户名
    private String loginName;
    // 密码
    private String password;

    public UserToken(String loginName, String password) {
        this.loginName = loginName;
        this.password = password;
    }

    @Override
    public Object getPrincipal() {
        return loginName;
    }

    @Override
    public Object getCredentials() {
        return password;
    }

    public String getLoginName() {
        return loginName;
    }

    public void setLoginName(String loginName) {
        this.loginName = loginName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return (new ReflectionToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) {
            protected boolean accept(Field f) {
                return super.accept(f) && !f.getName().equals("password");
            }
        }).toString();
    }
}
